<?php
declare (strict_types = 1);

namespace app\middleware;

use app\model\Users;
use think\facade\View;

class Check
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        //登录
//        $uid = session('uid');
//        if (!$uid){
//            return redirect('/login.html');
//        }
//        $user = new Users();
//        //获取用户信息
//        $user_info = $user->get_info(['id'=>base64_decode($uid)]);
//        if (!$user_info){
//            return redirect('/login.html');
//        }
//        $user_info = $user_info->toArray();
//        $request->uid = $user_info['id'];
//        $request->mobile = $user_info['mobile'];
//        $request->face = $user_info['face'];
//        $request->password = $user_info['password'];
//        $request->salt = $user_info['salt'];
//        View::assign('id',$user_info['id']);
//        View::assign('uid',$uid);
//        View::assign('username',$user_info['username']);
//        View::assign('nickname',$user_info['nickname']);
//        View::assign('truename',$user_info['truename']);
//        View::assign('face',$user_info['face']?$user_info['face']:'/static/images/users/face.png');
//        View::assign('mobile',$user_info['mobile']);
//        View::assign('sex',$user_info['sex']);
//        View::assign('reg_time',date('Y-m-d H:i:s',$user_info['reg_time']));
//        View::assign('signs',$user_info['signs']?$user_info['signs']:'你还没有签名...');
        View::assign('nickname','vip管理');
        View::assign('face','/static/images/users/face.png');
        return $next($request);
    }
}
